public class Test04 {
    //https://leetcode.cn/problems/single-number-ii/submissions/562008787/
    public int singleNumber(int[] nums) {
        int ret = 0;
        for(int i = 0 ; i < 32 ;i++){
            //依次修改ret中的每一个bit位
            int sum =  0;
            for(int x : nums){
                if(((x >> i) & 1) == 1){
                    sum++;
                }
            }
            sum %= 3;
            if(sum == 1) ret |= 1<<i;
        }
        return ret;

    }
}
